// 封装登录接口
// 跟之前人资当中 api 文件夹一样
import { request } from '@/utils/request'
import type { CodeType, Patient, PatientList, User, UserInfo } from '@/types/user'

export const loginByPassword = (mobile: string, password: string) => {
  return request<User>('/login/password', 'post', { mobile, password })
}
// 获取手机验证码
export const loginMessage = (mobile: string, type: CodeType) => {
  return request('/code', 'get', { mobile, type })
}
//手机号码登录
// 获取手机验证码
export const loginMessagenumber = (mobile: string, code: string) => {
  return request<User>('/login', 'post', { mobile, code })
}
// 获取个人用户信息
export const userInformation = () => {
  return request<UserInfo>('/patient/myUser')
}
// 查询患者信息
// 获取家庭档案病人列表
export const getPatientList = () => request<PatientList>('/patient/mylist')
// 添加患者
export const addPatient = (payload: Patient) => {
  return request('/patient/add', 'post', payload)
}
// 编辑患者
export const editPatient = (patient: Patient) =>
  request('/patient/update', 'PUT', patient)

export const delPatient = (id: string | number) =>
  request(`/patient/del/${id}`, 'DELETE',)